<?php
/**
* @file $Id: General_Info.inc.php 504 2007-05-11 18:01:06Z focus-sis $
* @package Focus/SIS
* @copyright Copyright (C) 2006 Andrew Schmadeke. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.txt
* Focus/SIS is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.txt for copyright notices and details.
*/

echo '<TABLE border=0 cellpadding=6>';
echo '<TR>';
// IMAGE
if($_REQUEST['student_id']!='new' && ($file = @fopen($StudentPicturesPath.($syear = UserSyear()).'/'.UserStudentID().'.JPG','r') || $file = @fopen($StudentPicturesPath.($syear = (UserSyear()-1)).'/'.UserStudentID().'.JPG','r')))
{
	echo '<TD><IMG SRC="'.$StudentPicturesPath.$syear.'/'.UserStudentID().'.JPG" width=150></TD><TD valign=top><TABLE cellpadding=5><TR><TD>';
	fclose($file);
}
else
	echo '<TD colspan=2><TABLE cellpadding=5><TR><TD valign=bottom>';

// single-quotes mess up the next line (add html within addhtml) ... it's not worth the brain power to fix this ...
if($_REQUEST['student_id']=='new' || strpos($student['FIRST_NAME'],"'")!==false || strpos($student['LAST_NAME'],"'")!==false || strpos($student['MIDDLE_NAME'],"'")!==false)
	echo '<TABLE><TR><TD>'.TextInput($student['FIRST_NAME'],'students[FIRST_NAME]',_('First'),'size=12 maxlength=50').' </TD><TD>'.TextInput($student['MIDDLE_NAME'],'students[MIDDLE_NAME]',_('Middle'),'size=3 maxlength=50').' </TD><TD>'.TextInput($student['LAST_NAME'],'students[LAST_NAME]',_('Last'),'size=12 maxlength=50').'</TD><TD>'.SelectInput($student['NAME_SUFFIX'],'students[NAME_SUFFIX]',_('Suffix'),array('Jr.'=>'Jr.','Sr.'=>'Sr.','II'=>'II','III'=>'III','IV'=>'IV','V'=>'V')).'</TD></TR></TABLE>';
else
	echo '<DIV id=student_name><div onclick=\'addHTML("<TABLE><TR><TD>'.str_replace('"','\"',TextInput($student['FIRST_NAME'],'students[FIRST_NAME]',_('First'),'maxlength=50',false)).' </TD><TD>'.str_replace('"','\"',TextInput($student['MIDDLE_NAME'],'students[MIDDLE_NAME]',_('Middle'),'size=3 maxlength=50',false)).' </TD><TD>'.str_replace('"','\"',TextInput($student['LAST_NAME'],'students[LAST_NAME]',_('Last'),'maxlength=50',false)).'</TD><TD>'.str_replace('"','\"',SelectInput($student['NAME_SUFFIX'],'students[NAME_SUFFIX]',_('Suffix'),array('Jr.'=>'Jr.','Sr.'=>'Sr.','II'=>'II','III'=>'III','IV'=>'IV','V'=>'V'),'N/A','',false)).'</TD></TR></TABLE>","student_name",true);\'>'.$student['FIRST_NAME'].' '.$student['MIDDLE_NAME'].' '.$student['LAST_NAME'].' '.$student['NAME_SUFFIX'].'</div></DIV><small>'._('Name').'</small>';
echo '</TD>';

echo '<TD valign=bottom>';
if($_REQUEST['student_id']=='new')
	echo TextInput('','assign_student_id',_('Student ID'),'maxlength=10 size=10');
else
	echo UserStudentID().'<BR><small>'._('Student ID').'</small>';
echo '</TD>';

echo '<TD valign=bottom>';
if($_REQUEST['student_id']!='new' && $student['SCHOOL_ID'])
	$school_id = $student['SCHOOL_ID'];
else
	$school_id = UserSchool();
$sql = "SELECT ID,TITLE FROM SCHOOL_GRADELEVELS WHERE SCHOOL_ID='".$school_id."' ORDER BY SORT_ORDER";
$QI = DBQuery($sql);
$grades_RET = DBGet($QI);
unset($options);
if(count($grades_RET))
{
	foreach($grades_RET as $value)
		$options[$value['ID']] = $value['TITLE'];
}
if($_REQUEST['student_id']!='new' && $student['SCHOOL_ID']!=UserSchool())
{
	$allow_edit = $_FOCUS['allow_edit'];
	$AllowEdit = $_FOCUS['AllowEdit'][$_REQUEST['modname']];
	$_FOCUS['AllowEdit'][$_REQUEST['modname']] = $_FOCUS['allow_edit'] = false;
}

if($_REQUEST['student_id']=='new')
	$student_id = 'new';
else
	$student_id = UserStudentID();

//if(VerifyDate($_REQUEST['day_values']['STUDENT_ENROLLMENT']['new']['START_DATE'].'-'.$_REQUEST['month_values']['STUDENT_ENROLLMENT']['new']['START_DATE'].'-'.$_REQUEST['year_values']['STUDENT_ENROLLMENT']['new']['START_DATE']))
//	unset($student['GRADE_ID']);

echo SelectInput($student['GRADE_ID'],'values[STUDENT_ENROLLMENT]['.$student_id.'][GRADE_ID]',_('Grade').' <font color=red>*</font>',$options);
echo '</TD>';

if($_REQUEST['student_id']!='new' && $student['SCHOOL_ID']!=UserSchool())
{
	$_FOCUS['allow_edit'] = $allow_edit;
	$_FOCUS['AllowEdit'][$_REQUEST['modname']] = $AllowEdit;
}

echo '</TR></TABLE>';
if(User('PROFILE')=='admin' || User('PROFILE')=='student')
{
	echo '<TABLE cellpadding=5 border=0><TR>';
	echo '<TD>';
	echo TextInput($student['USERNAME'],'students[USERNAME]',_('Username'),'','force');
	echo '</TD>';
	echo '<TD>';
	//echo TextInput($student['PASSWORD'],'students[PASSWORD]',_('Password'));
	echo TextInput(array($student['PASSWORD'],str_repeat('*',strlen($student['PASSWORD']))),'students[PASSWORD]',_('Password'),'','force');
	echo '</TD>';
}

if(User('PROFILE')=='admin')
{
	echo '<TD>';
	$profiles_RET = DBGet(DBQuery("SELECT ID,TITLE FROM USER_PROFILES WHERE PROFILE='student' ORDER BY TITLE"));
	$options = array();
	foreach($profiles_RET as $profile)
		$options[$profile['ID']] = $profile['TITLE'];

	echo SelectInput($student['PROFILE_ID'],'students[PROFILE_ID]',_('Profile'),$options,false);
	echo '</TD>';
}

if(User('PROFILE')=='admin' || User('PROFILE')=='student')
	echo '</TR></TABLE>';

if($_REQUEST['student_id']!='new')
{
	echo '</TD>';
	echo '</TR>';
	echo '</TABLE>';
}
echo '<HR>';
$_REQUEST['category_id'] = 1;

include $staticpath.'modules/Students/includes/Other_Info.inc.php';

if($_REQUEST['student_id']!='new' && $student['SCHOOL_ID']!=UserSchool() && $student['SCHOOL_ID'])
	$_FOCUS['AllowEdit'][$_REQUEST['modname']] = $_FOCUS['allow_edit'] = false;
include 'modules/Students/includes/Enrollment.inc.php';

if($_REQUEST['student_id']=='new')
{
	$_REQUEST['category_id'] = 'required';
	include $staticpath.'modules/Students/includes/Other_Info.inc.php';
	
	$_REQUEST['category_id'] = 1;
	
}
?>